import 'package:mvvm_provider/base/base_state.dart';
import 'package:mvvm_provider/page/mine/data/model/info_model.dart';
import 'package:mvvm_provider/page/mine/data/repository/mine_repository.dart';
import 'package:mvvm_provider/page/mine/states/mine_detail_state.dart';
import '../../../base/base_view_model.dart';
import '../../../config/handle_state.dart';
import '../../../model/response_model.dart';
import '../../../net/ltt_https.dart';
import '../../../net/http_config.dart';

class MineDetailViewModel extends BaseViewModel<MineDetailState> {
  MineDetailViewModel() : super(MineDetailState());

  /// 获取详情数据
  Future<void> geDetailData(int entityId) async {
    ResponseModel responseModel = await MineRepository.getDetailInfoData<InfoListModel>(entityId);
    state.netState = HandleState.handle(responseModel);
    if (state.netState == NetState.dataSuccessState) {
      state.model = responseModel.data;
    }
    notifyListeners();
  }

  void changeLikeStatus() {
    state.model?.isLike = !state.model!.isLike;
    notifyListeners();
  }
}
